package cn.com.haopy.yue.ai.db.service.hos.impl;

import cn.com.haopy.yue.ai.db.entity.arisk.AIRiskIllnessTopic;
import cn.com.haopy.yue.ai.db.mapper.arisk.AIRiskIllnessTopicMapper;
import cn.com.haopy.yue.ai.db.service.BaseServiceImpl;
import cn.com.haopy.yue.ai.db.service.hos.AIRiskIllnessTopicService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: TODO
 * @Author DuTao
 * @Date 2025/3/31 15:02
 */
@Service
public class AIRiskIllnessTopicServiceImpl extends BaseServiceImpl<AIRiskIllnessTopicMapper, AIRiskIllnessTopic>
        implements AIRiskIllnessTopicService {
    @Autowired
    private AIRiskIllnessTopicMapper mapper;

    @Override
    public boolean deleteByIllnessId(Integer illnessId) {
        LambdaQueryWrapper<AIRiskIllnessTopic> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessTopic::getIllnessId, illnessId);
        return super.remove(queryWrapper);
    }

    @Override
    public List<AIRiskIllnessTopic> getByIllnessId(Integer illnessId) {
        LambdaQueryWrapper<AIRiskIllnessTopic> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessTopic::getIllnessId, illnessId);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<AIRiskIllnessTopic> getAll(Integer illnessId) {
        LambdaQueryWrapper<AIRiskIllnessTopic> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessTopic::getIllnessId, illnessId);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<AIRiskIllnessTopic> getDeleteAll(Integer illnessId) {
        return mapper.getDeleteList(illnessId);
    }

    @Override
    public AIRiskIllnessTopic getByCondition(Integer illnessId, Integer topicId) {
        LambdaQueryWrapper<AIRiskIllnessTopic> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessTopic::getIllnessId, illnessId);
        queryWrapper.eq(AIRiskIllnessTopic::getTopicId, topicId);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public AIRiskIllnessTopic getByIllnessIdAndIndexId(Integer illnessId, Integer topicId) {
        return mapper.getByIllnessIdAndIndexId(illnessId, topicId);
    }

    @Override
    public Integer updateDelete(AIRiskIllnessTopic checkIndexEntity22) {
        return mapper.updateDelete(checkIndexEntity22.getUpdateBy(), checkIndexEntity22.getDeleted(), checkIndexEntity22.getId());
    }

    @Override
    public List<AIRiskIllnessTopic> getByIllnessIds(List<Integer> illnessIds) {
        LambdaQueryWrapper<AIRiskIllnessTopic> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(AIRiskIllnessTopic::getIllnessId, illnessIds);
        queryWrapper.groupBy(AIRiskIllnessTopic::getTopicId);
        return baseMapper.selectList(queryWrapper);
    }
}
